﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.VisualBasic;
//引入如下命名空间用于验证
using System.Text.RegularExpressions;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        if (!Regex.IsMatch(txtmonth.Text.Trim(), @"^\+?[1-9][0-9]*$"))	//判断输入的是否是大于0的数字
        {
            Page.RegisterClientScriptBlock("", "<script>alert('请输入数字！');</script>");//弹出提示信息
        }
        else
        {
            if (Convert.ToInt32(txtmonth.Text.Trim()) >= 1 && Convert.ToInt32(txtmonth.Text.Trim()) <= 12)
            {
                string season = string.Empty;
                int month = Convert.ToInt32(txtmonth.Text.Trim());
                switch (month)
                {
                    case 12:
                    case 1:
                    case 2:
                        season = "冬季"; break;
                    case 3:
                    case 4:
                    case 5:
                        season = "春季"; break;
                    case 6:
                    case 7:
                    case 8:
                        season = "夏季"; break;
                    case 9:
                    case 10:
                    case 11:
                        season = "秋季"; break;
                    default:
                        season = "不存在"; break;
                }
                txtShow.Text = season;//根据输入的当前月份查询出相应的季节
            }
            else
            {
                Page.RegisterClientScriptBlock("", "<script>alert('您输入的月份错误，请重新输入');</script>");
            }
        }
    }
}
